# 拿出最少数目的魔法豆
def minimum_removal(beans: list[int]):
    beans.sort()
    total = sum(beans)
    lefts = [(len(beans) - i) * v for i, v in enumerate(beans)]
    max_left = max(lefts)
    return total - max_left


print(minimum_removal([4, 7, 8, 10]))
